package com.bwie.ES;

import com.bwie.pojo.User;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;

import java.util.List;

public class ESserviceImpl {
//    @Autowired
//    ElasticsearchRestTemplate esTemplate;
//
//    public List<User> getListUser(User user){
//        PageRequest of = PageRequest.of(0, 2);
//        BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
//        //模糊查询
//        boolQueryBuilder.must(new MatchQueryBuilder("userName",user.getUserName()));
//        //精确查询
//        boolQueryBuilder.must(new TermQueryBuilder("userId",user.getUserId()));
//        NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
//        NativeSearchQuery build = nativeSearchQueryBuilder.withQuery(boolQueryBuilder)
//                .withPageable(of)
//                .build();
//        esTemplate.search(build,null);
//    }
}
